package com.application.metroscanner;

public class Ride implements Comparable<Object>{
	public static final int DAY_OF_WEEK = 0;
	public static final int MONTH = 1;
	public static final int DAY = 2;
	public static final int HOURS = 3;
	public static final int MINUTES = 4;
	public static final int TIME = 5;
	public static final int RATING = 6;

	int minutes;
	int hours;
	long rideTime;
	int rating;
	int dayOfWeek;
	int day;
	int month;

	public Ride(String iValues) {
		// format : dayOfWeek;month;day;hour;minute;time;rating
		String[] split = iValues.split(";");
		hours = Integer.parseInt(split[HOURS]);
		minutes = Integer.parseInt(split[MINUTES]);
		rideTime = Long.parseLong(split[TIME]);
		rating = Integer.parseInt(split[RATING]);
		dayOfWeek = Integer.parseInt(split[DAY_OF_WEEK]);
		day = Integer.parseInt(split[DAY]);
		month = Integer.parseInt(split[MONTH]);
	}
	
	public int getHours() {
		return hours;
	}

	public void setHours(int hours) {
		this.hours = hours;
	}

	public int getMinutes() {
		return minutes;
	}

	public void setMinutesFromMidnight(int iMinutes) {
		this.minutes = iMinutes;
	}

	public long getRideTime() {
		return rideTime;
	}

	public void setRideTime(long rideTime) {
		this.rideTime = rideTime;
	}

	public int getRating() {
		return rating;
	}

	public void setRating(int rating) {
		this.rating = rating;
	}

	public int getDayOfWeek() {
		return dayOfWeek;
	}

	public void setDayOfWeek(int dayOfWeek) {
		this.dayOfWeek = dayOfWeek;
	}

	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}

	public int getMonth() {
		return month;
	}

	public void setMonth(int month) {
		this.month = month;
	}

	@Override
	public int compareTo(Object iRide) {
		Ride ride2 = (Ride)iRide;
		int diff = (minutes + hours * 60) - (ride2.getMinutes() + ride2.getHours() * 60);
		if (diff < 0) {
			return -1;
		} else if (diff > 0) {
			return 1;        	
		} else {
			return 0;
		}
	}
}
